"use client"; import { GameListRep, GameRequest } from "@/api/home"; import { userInfoApi } from "@/api/login"; import { UserInfoRep, UserVipInfo, Wallet, cleanBounsApi, getUserMoneyApi, getUserTransferApi, } from "@/api/user"; import { BalanceContent, BonusContent, FreeContent, ReplayContent, } from "@/components/ModalPopup/WalletDescribeModal"; import TipsModal, { ModalProps } from "@/components/TipsModal"; import useGame from "@/hooks/useGame"; import { Link, useRouter } from "@/i18n/routing"; import { useWalletStore } from "@/stores/useWalletStore"; import { WalletEnum } from "@/types"; import { vipImages } from "@/utils/constant"; import { flatPoint, percentage } from "@/utils/methods"; import { Badge, Button, Mask, ProgressBar, Toast } from "antd-mobile"; import { useTranslations } from "next-intl"; import Image from "next/image"; import { Fragment, useEffect, useRef, useState } from "react"; type Props = { userInfo: UserInfoRep; userMoney: Wallet; userVip: UserVipInfo; }; const VipCard = (props: { userVip: UserVipInfo }) => { const { userVip } = props; const t = useTranslations("ProfilePage"); // Vip 图标 const vipIconElement = vipImages.map((item, index) => { if (item.leve === userVip?.vip_level) { return ( {"vip"} {item.leve} ); } }); if (!userVip) return null; return (
{vipIconElement}
{/*
{userVip.vip_exp}xp
*/}
VIP{userVip?.vip_level} {t("expTips", { exp: flatPoint(userVip.vip_score_exp - userVip.vip_exp), })} VIP {userVip.vip_next_level}
); }; const WalletCard = (props: { userMoney: Wallet }) => { const { userMoney } = props; const t = useTranslations("ProfilePage"); const tcdoe = useTranslations(); const tipsRef = useRef(null); const [tipsStatus, setTipsStatus] = useState("Bonus"); const modalHandler = (key: keyof typeof WalletEnum) => { setTipsStatus(key); tipsRef.current?.onOpen(); }; // 未完成游戏 const gameModelRef = useRef(null); const game = useRef<(GameListRep & { mode: GameRequest["mode"] }) | null>(null); // 彩金、免费币、重玩币提现到钱包操作 const handleAcquire = async (wallet_type: number, transfer: boolean) => { if (!transfer) return; // 先判断是否有未完成的游戏 const { data }: any = await userInfoApi(); // 如果有未完成游戏 彩金游戏-2、免费游戏-3、重玩游戏-4 if (wallet_type === 2 && data.play_list && data.play_list.length > 0) { game.current = data.play_list[0]; game.current!.mode = 1; gameModelRef.current?.onOpen(); return; } if (wallet_type === 3 && data.free_game_list && data.free_game_list.length > 0) { game.current = data.free_game_list[0]; gameModelRef.current?.onOpen(); game.current!.mode = 2; return; } if (wallet_type === 4 && data.lose_game_list && data.lose_game_list.length > 0) { game.current = data.lose_game_list[0]; game.current!.mode = 3; gameModelRef.current?.onOpen(); return; } getUserTransferApi({ wallet_type }) .then((res) => { if (res.code === 200) { Toast.show(tcdoe("code.200")); setTimeout(() => { tipsRef.current?.onClose(); }, 1000); } }) .catch((error) => { Toast.show(tcdoe(`code.${error.data.code}`)); }); }; const { getGameUrl } = useGame(); const goGame = () => { const current = game.current; getGameUrl(current!, { id: current?.id + "", mode: game.current?.mode! }); tipsRef.current?.onClose(); gameModelRef.current?.onClose(); }; return ( <> {t("modalTitle")} } > {/*现金*/} {tipsStatus === WalletEnum.Balance ? : null} {/* 彩金*/} {tipsStatus === WalletEnum.Bonus ? ( ) : null} {/* 免费币 */} {tipsStatus === WalletEnum.Free ? ( ) : null} {/* 重玩币 */} {tipsStatus === WalletEnum.Replay ? ( ) : null} {/* 提现拦截 */}

Existem jogos de bônus pendentes que não podem iniciar a retirada.

modalHandler(WalletEnum.Balance)} >
{t("balance")} {/* question */}
?
brl {userMoney.score || 0.0}
modalHandler(WalletEnum.Bonus)} >
{t("bonus")}
?
brl {userMoney.point || 0.0}
modalHandler(WalletEnum.Free)} > = (userMoney?.free_transfer_min || 0) ? Badge.dot : null } style={{ right: "10px" }} >
{t("free")}
?
brl {userMoney.free_score || 0.0}
modalHandler(WalletEnum.Replay)} > = (userMoney?.lose_transfer_min || 0) ? Badge.dot : null } style={{ right: "10px" }} >
{t("replay")}
?
brl {userMoney.lose_score || 0.0}
); }; const NoBounsWarn = ({ visible, onClose, onConfirm }: any) => { const doClose = () => { if (typeof onClose === "function") onClose(); }; const doConfirm = () => { if (typeof onConfirm === "function") onConfirm(); }; return (
A demanda atual de fluxo de retirada de bônus é excessiva,Se esvaziar o bônus e retirar a demanda de água corrente?
); }; export const ProfileHeader = (props: Props) => { const { userInfo, userVip } = props; const t = useTranslations("ProfilePage"); const { wallet, setWallet } = useWalletStore((state) => ({ wallet: state.wallet, setWallet: state.setWallet, })); const router = useRouter(); const [isShowNoBounsWarn, setIsShowNoBounsWarn] = useState(false); const [isShowed, setIsShowed] = useState(false); useEffect(() => { const curMul = wallet.target_point_rollover / ((wallet?.score || 0) + (wallet.point || 0)); const config = wallet.no_bonus_config; if (curMul >= (config || 0) && !isShowed) { setIsShowNoBounsWarn(true); setIsShowed(true); } }, [wallet]); const handler = () => { if (!!wallet.score) { router.push("/withdraw"); } else { Toast.show("no money "); } }; const doConfirm = async () => { Toast.show({ icon: "loading", maskClickable: false, }); setIsShowNoBounsWarn(false); const res = await cleanBounsApi(1); if (res?.code && [6001, 6002].includes(res?.data?.code)) { const str = t(`bouns${res?.data?.code}`); Toast.show({ content: str, icon: "fail", }); } Toast.show({ content: t("success"), icon: "success", }); const walletRes = await getUserMoneyApi(); setWallet(walletRes?.data); }; return ( <>
{"avatar"}
{t("Conta")} {userInfo?.user_phone || ""}
{/*vipcard*/}
{t("Depósito")}

{t("Sacar")}

setIsShowNoBounsWarn(false)} onConfirm={doConfirm} > ); };